package com.hinnotek.amoeba.viewmodels


import androidx.lifecycle.viewModelScope
import com.hinnotek.amoeba.base.BaseBean
import com.hinnotek.amoeba.bean.old.CompanyPhonePayByIdBean
import com.hinnotek.amoeba.bean.old.CompanyPhonePayPageByUserIdBean
import com.hinnotek.amoeba.repo.PhoneRepo
import com.lee.common.base.BaseViewModel
import com.lee.common.network.net.StateLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class PhoneViewModel @Inject constructor(private val repository: PhoneRepo) :
    BaseViewModel() {

    val baseData = StateLiveData<BaseBean>()

    fun addCompanyPhonePay(body: RequestBody): StateLiveData<BaseBean> {
        viewModelScope.launch {
            repository.addCompanyPhonePay(body,baseData)
        }
        return baseData
    }


    val companyPhonePayByIdData = StateLiveData<CompanyPhonePayByIdBean>()

    fun getCompanyPhonePayById(companyPhonePayId: Int): StateLiveData<CompanyPhonePayByIdBean> {
        viewModelScope.launch {
            repository.getCompanyPhonePayById(companyPhonePayId,companyPhonePayByIdData)
        }
        return companyPhonePayByIdData
    }

    val companyPhonePayPageByUserIdData = StateLiveData<MutableList<CompanyPhonePayPageByUserIdBean>>()

    fun getCompanyPhonePayPageByUserId(applyUserId: Int, pageNo: Int, pageSize: Int) : StateLiveData<MutableList<CompanyPhonePayPageByUserIdBean>> {
        viewModelScope.launch {
            repository.getCompanyPhonePayPageByUserId(applyUserId,pageNo,pageSize,companyPhonePayPageByUserIdData)
        }
        return companyPhonePayPageByUserIdData
    }


}